import { loginSimple, getMemberProfile } from '@/http/user'
export default {
  namespaced: true,
  state: {
    // 用户信息
    profile: null,
    memberProfile: null
  },
  getters: {},
  mutations: {
    setProfile(state, payload) {
      state.profile = payload
    },
    setMemberProfile(state, payload) {
      console.log(payload);
      state.memberProfile = payload
    }
  },
  actions: {
    // 获取用户信息
    async fetchProfile({ commit }, data) {
      const res = await loginSimple(data)
      commit('setProfile', res.result)
      console.log(res);
    },
    async fetchMemberProfile({ commit }) {
      const res = await getMemberProfile()
      commit('setMemberProfile', res.result)
      return res.result
    }
  }
}